L1-096 谁管谁叫爹

题目 L1-096 谁管谁叫爹

image-5da1d890

思路分析

代码实现

#include<bits/stdc++.h>

using namespace std;

#define endl '\n'

using ll = long long;

using ull = unsigned long long;

using PII = pair<int,int>;

using Pll = pair<ll,ll>;

int dx[4]= {-1,0,1,0},dy[4]= {0,1,0,-1};

const int inf = 0x3f3f3f3f;

int main() {

	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

	int n;cin>>n;

	while(n--){

		ll na,nb;cin>>na>>nb;

		ll sa=0,sb=0;

		ll tmpa=na,tmpb=nb;

		while(tmpa){

			sa+=tmpa%10;

			tmpa/=10;

		}

		while(tmpb){

			sb+=tmpb%10;

			tmpb/=10;

		}

		if(na%sb==0 && nb%sa!=0)	cout<<"A"<<endl;

		else if(nb%sa==0 && na%sb!=0)	cout<<"B"<<endl;

		else	cout<<((na>nb)?"A":"B")<<endl;

	}

	return 0;

}

同类题型

视频讲解


⬅️ L1-095 分寝室 🏠 00-天梯赛 ➡️ L1-097 编程解决一切